package cn.com.agree.bigdata.vmdatahandle.utils;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

public class AgreeDateTime {

    public static String timestampToLocalDateTimeStr(long milliseconds, String pattern) {
        LocalDateTime localDateTime = Instant.ofEpochMilli(milliseconds).atZone(ZoneOffset.ofHours(8)).toLocalDateTime();

        // 指定模式
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
        // 将 LocalDateTime 格式化为字符串
        return localDateTime.format(dateTimeFormatter);
    }
}
